// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'

import FastClick from 'fastclick'
import App from './App.vue'
import router from './router/router'
import store from './store/store'

FastClick.attach(document.body);

Vue.config.productionTip = false;

//plugins
import 'amfe-flexible/index.js';
import 'amfe-flexible/index.js';
import axios from 'axios';

Vue.prototype.axios = axios;


//my plugins
import API from './API/api'
import moment from 'moment'
import filters from './filters/filters'
import {ToastPlugin} from 'vux'

// Vue.use(ToastPlugin);

// 默认参数
Vue.use(ToastPlugin, {type: 'text'});

Vue.prototype.$api = API;
Vue.prototype.moment = moment;
Vue.prototype.routerTo = function (address) {
  this.$router.push(address);
};
router.beforeEach((to, from, next) => {
  switch (to.name) {
    case 'awesome':
      store.commit('changeIndex', 0);
      break;
    case 'subscriptions':
      store.commit('changeIndex', 1);
      break;
    case 'positions':
      store.commit('changeIndex', 2);
      break;
    case 'mine':
      store.commit('changeIndex', 3);
      break;
    default:
      store.commit('changeIndex', 4);
      break;
  }
  next();
});


/* eslint-disable no-new */
new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app-box');
